#pragma once
#include "src/project_settings.h"

#ifndef QTCV_STATIC_H
#define QTCV_STATIC_H

#include <QtWidgets/QMainWindow>
#include "ui_qtcv_static.h"

#include <QWidget>
#include <QPushButton>
#include <QHBoxLayout>
#include <QProgressBar>
#include <QLabel>
#include <QListView>
#include <QSplitter>
#include <QSlider>
#include <QFileDialog>
#include <QMessageBox>
#include <QStandardItemModel>
#include <QMenuBar>
#include <QTimer>
#include <QDir>
#include <QDateTime>
#include <QDoubleValidator>
#include <QLineEdit>
#include <QScrollArea>
#include <QThread>


#include "ImageWidget.h"
#include "VideoCropper.h"

#include <stdlib.h>

#include <vector>


#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

class QTCV_static : public QMainWindow
{
	Q_OBJECT

public:
	QTCV_static(QWidget *parent = 0);
	~QTCV_static();

private:
	Ui::QTCV_staticClass ui;
	void init(void);
	//buttons bar
	QPushButton *btnShowInfo, *btnPreview, *btnProcess, *btnOpenFile, *btnSave;

	bool threadrunning;

	QLabel *lbResize; QDoubleValidator *doubleValidator; QDoubleValidator *doubleValidatorFrame;
	QLabel *lbRect, *lbInit, *lbEnd; 

	long maxFrames;
	QLineEdit *editRect;
	QLineEdit *editResize;
	QLineEdit *editInit;
	QLineEdit *editEnd;

	QVBoxLayout *topLayout;
	QHBoxLayout *boxButtons, *boxProps;

	QHBoxLayout *hboxStatus, *boxImages;
	QProgressBar *progressBar;
	QLabel *textStatus;

	QListView *listInfo;
	QStandardItemModel *modelListInfo;

	QVBoxLayout *box, *boxListView;
	QWidget *mainBox;
	QScrollArea *qScrollArea;
	QSplitter *splitter;

	QWidget *wSlider;
	QSlider *sliderFrames;
	QLabel *labelSlider;
	QVBoxLayout *boxSlider;

	ImageWidget *imgWid;

	//Open File
	QFileDialog fileDialog;
	QString pathInputVideo;

	QDir dirDialog;
	QString pathOutputVideoFile;

	VideoCapture cap;
	VideoCropper *cropper;
	QMutex *mutexCropper;

public slots:

	//GUI
	void btnOpenFile_clicked(void);
	void btnPreview_clicked(void);
	void btnProcess_clicked(void);
	void btnShowInfo_clicked(void);
	void btnSave_clicked(void);

	void addMessageToInfoBox(QString msg);
	void sendProgressBar(long max, long value);
	void setStatusBarText(QString text);

	void sendRect(QString);
	void process_finished(void);


	void slider_valueChanged();
	void slider_sliderMoved(int);

};

#endif // QTCV_STATIC_H
